
var http =require('http')
var fs =require('fs')
const app =http.createServer()


app.on('request',(req,res)=>{
	fs.readFile(__dirname+'/index.html',function(err,data){
		if(err){
			res.writeHead(500)
			return res.end('Error loading index.html')
		}
		res.writeHead(200)
		res.end(data)
	})
})
app.listen(3000,()=>{
	console.log('运行了程序')
})
var io =require('socket.io')(app)
io.on('connection',function(socket){
	console.log('用户连接了')
	socket.emit('send',{name:'zs'})
	socket.on('say',(data)=>{
		console.log(data,data.name)
	})

})